<?php
namespace App\TaskService;

use App\Utils\Excel;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Task\TaskExecutor;
use Hyperf\Task\Annotation\Task;
use Hyperf\Utils\ApplicationContext;

class ExcelTask
{
    /**
     * @Task
     */
    public function raw($head,$data){
        //导出文件名称
        //$filename='导出文件名称.xlsx';
        //表头映射与字段排序
        //$head=['id'=>'id','name'=>'122132'];
        //导出内容二维数组
        //    $data=[
        //         ['id'=>1,'name'=>'测试']
        //    ];
        // 少于4W条数据可调用task进程下载导出
        // $content=$this->container->get(\App\TaskService\ExcelTask::class)->raw($head,$data);
        // return \App\Utils\Excel::download($filename,$content);
        return Excel::create($head,$data)->raw();
    }
}